//
//  RootTabBarViewController.m
//  Douban-01
//
//  Created by lanou3g on 16/7/27.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "RootTabBarViewController.h"
//#import "ZiDingYiTabBar.h"
#import "ZYTabBar.h"
#import "Header.h"

@interface RootTabBarViewController ()<ZYTabBarDelegate>

@end

@implementation RootTabBarViewController

- (void)viewWillAppear:(BOOL)animated{
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    设置tabBarItem不被渲染
    for (UITabBarItem *itme in self.tabBar.items) {
        itme.image = [itme.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        itme.selectedImage = [itme.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    }
    
    [self configureButton];
    
}

- (void)configureButton {
    ZYTabBar *tabBar = [ZYTabBar new];
    tabBar.delegate = self;
    ZYPathItemButton *itemButton_1 = [[ZYPathItemButton alloc]initWithImage:[UIImage imageNamed:@"chooser-moment-icon-music"]highlightedImage:[UIImage imageNamed:@"chooser-moment-icon-music-highlighted"]backgroundImage:[UIImage imageNamed:@"chooser-moment-button"]backgroundHighlightedImage:[UIImage imageNamed:@"chooser-moment-button-highlighted"]];
    ZYPathItemButton *itemButton_2 = [[ZYPathItemButton alloc]initWithImage:[UIImage imageNamed:@"chooser-moment-icon-place"]highlightedImage:[UIImage imageNamed:@"chooser-moment-icon-place-highlighted"]backgroundImage:[UIImage imageNamed:@"chooser-moment-button"]backgroundHighlightedImage:[UIImage imageNamed:@"chooser-moment-button-highlighted"]];
    
    ZYPathItemButton *itemButton_3 = [[ZYPathItemButton alloc]initWithImage:[UIImage imageNamed:@"chooser-moment-icon-camera"]highlightedImage:[UIImage imageNamed:@"chooser-moment-icon-camera-highlighted"]backgroundImage:[UIImage imageNamed:@"chooser-moment-button"]backgroundHighlightedImage:[UIImage imageNamed:@"chooser-moment-button-highlighted"]];
    
    ZYPathItemButton *itemButton_4 = [[ZYPathItemButton alloc]initWithImage:[UIImage imageNamed:@"chooser-moment-icon-thought"]highlightedImage:[UIImage imageNamed:@"chooser-moment-icon-thought-highlighted"]backgroundImage:[UIImage imageNamed:@"chooser-moment-button"]backgroundHighlightedImage:[UIImage imageNamed:@"chooser-moment-button-highlighted"]];
    
    ZYPathItemButton *itemButton_5 = [[ZYPathItemButton alloc]initWithImage:[UIImage imageNamed:@"chooser-moment-icon-sleep"]highlightedImage:[UIImage imageNamed:@"chooser-moment-icon-sleep-highlighted"]backgroundImage:[UIImage imageNamed:@"chooser-moment-button"]backgroundHighlightedImage:[UIImage imageNamed:@"chooser-moment-button-highlighted"]];
    tabBar.pathButtonArray = @[itemButton_1 , itemButton_2 , itemButton_3, itemButton_4 , itemButton_5];
    tabBar.basicDuration = 0.3;
    tabBar.allowSubItemRotation = YES;
    tabBar.bloomRadius = 100;
    tabBar.allowCenterButtonRotation = YES;
    tabBar.bloomAngel = 150;
    //kvc实质是修改了系统的_tabBar
    [self setValue:tabBar forKeyPath:@"tabBar"];
    
}

- (void)pathButton:(ZYTabBar *)ZYTabBar clickItemButtonAtIndex:(NSUInteger)itemButtonIndex{
    NSLog(@" 点中了第%ld个按钮" , itemButtonIndex);
    __weak typeof(self) weakSelf = self;
    switch (itemButtonIndex) {
        case 0:
        {
            ShiPingViewController *VC = [[ShiPingViewController alloc]init];
            [weakSelf.navigationController pushViewController:VC animated:YES];
        }
            break;
        case 1:
        {
            DuanZiViewController *VC = [[DuanZiViewController alloc]init];
            [weakSelf.navigationController pushViewController:VC animated:YES];
        }
            
            break;
        case 2:
        {
            DianTaiViewController *VC = [[DianTaiViewController alloc]init];
            [weakSelf.navigationController pushViewController:VC animated:YES];
        }
            
            break;
        case 3:
        {
            QitaViewController *VC = [[QitaViewController alloc]init];
            [weakSelf.navigationController pushViewController:VC animated:YES];
        }
            break;
        default:
            return;
            break;
    }
    
}


//- (void)tabBarBtnClick:(ZiDingYiTabBar *)tabBar{
//   
//    NSLog(@"中间=====");
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (UIColor *)randomColor
{
    CGFloat r = arc4random_uniform(256);
    CGFloat g = arc4random_uniform(256);
    CGFloat b = arc4random_uniform(256);
    return [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0];
    
}



@end
